package com.unionpay.acp.config;

import com.unionpay.acp.sdk.SDKConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;


/**
 * @author caizw
 * @date 2018-08-23
 * @description:
 * <per>
 *      请求银联接入地址，获取证书文件，证书路径等相关参数初始化到SDKConfig类中
 *      在java main 方式运行时必须每次都执行加载
 *      如果是在web应用开发里,这个方法可使用监听的方式写入缓存,无须在这出现
 * </per>
 */
@Component
public class InitSdkConfig implements CommandLineRunner {
    private Logger logger = LoggerFactory.getLogger(InitSdkConfig.class);

    @Value("${test.union-pay.acp-sdk-path}")
    private String acpSdkPath;

    @Override
    public void run(String... strings) {
        logger.info("=======================  SDKConfig参数初始化  =======================");
        logger.info("=======================  "+ acpSdkPath +"  =======================");
        SDKConfig.getConfig().loadPropertiesFromPath(acpSdkPath);
        //SDKConfig.getConfig().loadPropertiesFromSrc();
    }
}
